In some earlier versions, the examples were tested in PHP v5.6, under command-line interpreter and Internet Information Server (IIS). In OPC Data Client 2019.2, the examples were tested in PHP 7.3.10 (VC15 x64 Thread Safe).
The examples use the COM extension for PHP. This extension can be enabled e.g. in following ways:
a) Add following to the php.ini file:
extension=ext/php_com_dotnet.dll
b) Use following in the php.ini file:
extension_dir = "ext"
extension=php_com_dotnet.dll
c) From IIS, under Internet Information Services (IIS) Manager, by PHP Manager: Use
[PHP_COM_DOTNET]
extension=php_com_dotnet.dll
In order to run the command-line examples, use
PHP.EXE –f “filename”
For easier troubleshooting of the command-line scripts, it is recommended that you enable the display_error option, e.g. in one of the following ways:
a) Use the following on the command line:
-d display_errors
b) Add following to the php.ini file:
display_errors = On
c) Copy the file php.ini-development over your php.ini file.
The provided examples are:
In order to run the Web-based examples, you need to configure your Web server to logically expose the physical directory where the examples are installed.
Examples in this folder are Web server scripts: the page, including OPC data, is generated on the server. The EasyOPC component must be installed on the server side, and the OPC server(s) must be accessible locally or remotely from the computer where EasyOPC component resides.
In IIS, a virtual directory needs to be created to point to the physical directory with the examples.
We have used roughly following steps to test the PHP Web examples with Apache:
We have also tested with FastCGI, using the steps outlined here: How to Configure FastCGI on WAMP... .
PHP cannot navigate between COM interfaces of an object, or provide an "amalgamated" set of members from multiple interfaces, when a specific interface is returned by a property or method. This leads to a problem if you want to downcast the object you have to a derived type.
For example, if you work with OPC UA Complex Data Extension, you may receive a UAGenericObject containing GenericData Object. PHP will allow you to access members declared on the GenericData Object, but that may not be enough. There are various derivations of the GenericData, such as the StructuredData. If you have received StructuredData, PHP will not give you any way to access the new members it has over the GenericData. In this particular case, we have provided methods on the GenericData Object such as AsStructuredData, which allow you to cast the received data appropriately.
It is not, however, possible to provide such methods in all situations and for object types. In such case, you can use the InteropHelper Object and its AsObject Method. By passing the object through this method, PHP is forced to use late binding, allowing the intended members be accessed.